﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using AxSHDocVw;


namespace Insurance_Quotation_App
{
    public partial class Results : System.Windows.Forms.Form
    {
        public Results()
        {
            InitializeComponent();
            calculateResults();
        }

        // i plan to put the different websites into different .cs files cuz its getting messy basically
        // only done it so far for Tenet and China.. China is still incomplete
        public void calculateResults()
        {
            // AXA();
            // HSBC.Run(axWebBrowser1, axWebBrowser2);
            // Tenet.Run(axWebBrowser1);
            China.Run(axWebBrowser1, axWebBrowser2);
            //TokioMarine.Run(axWebBrowser1);
        }
                
        private void AXA()      // contains code for AXA website
        {
            axWebBrowser1.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(axWebBrowser1_DocumentCompleteAXA);
            axWebBrowser1.Navigate("https://www.eservices.axa.com.sg/insurance/index.jsp");
        }

        private void axWebBrowser1_DocumentCompleteAXA(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            axWebBrowser1.DocumentComplete -= axWebBrowser1_DocumentCompleteAXA;

            Autofill.SetText(axWebBrowser1, "name", "username", "SAGT00657");
            Autofill.SetText(axWebBrowser1, "name", "password", "67431220Di");

            axWebBrowser1.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(axWebBrowser1_DocumentCompleteAXA2);
            Autofill.ClickButton(axWebBrowser1, "name", "Submit", "input");
        }

        private void axWebBrowser1_DocumentCompleteAXA2(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            axWebBrowser1.DocumentComplete -= axWebBrowser1_DocumentCompleteAXA2;

            axWebBrowser1.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(axWebBrowser1_DocumentCompleteAXA3);
            axWebBrowser1.Navigate("https://www.eservices.axa.com.sg/insurance/gs/servlet/com.ebao.gs.pol.nb.action.CreateQuotationAction");
            // Autofill.ClickButton(axWebBrowser1, "alt", "SmartDrive", "img");
        }

        private void axWebBrowser1_DocumentCompleteAXA3(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            axWebBrowser1.DocumentComplete -= axWebBrowser1_DocumentCompleteAXA3;

            // axWebBrowser1.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(axWebBrowser1_DocumentCompleteAXA4);
            Autofill.ClickButton(axWebBrowser1, "alt", "SmartDrive", "img");
        }

        
    }
}
